package com.bw.test;

import com.alibaba.fastjson.JSON;
import com.bw.entity.Book;
import com.bw.service.BookService;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class testBook {



    @Test
    public void test(){

        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring-ioc.xml");

        BookService bookService = applicationContext.getBean(BookService.class);


        List<Book> list = bookService.selectBookList("java");


    }

    @Test
    public void test00(){


        Book book = new Book();
        System.out.println(book.getClass()); // 打印这个对象的类名
    }
    @Test
    public void test1(){

        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring-ioc.xml");
        // 从容器中获取一个service
        BookService bookService = applicationContext.getBean(BookService.class);
        System.out.println(bookService);
        System.out.println(bookService.getClass());  // 代理对象的类名
        Book book = Book.builder().id(20).name("哈利波特").build();
        // 调用service的方法
        bookService.delBook(1);



    }
}
